'use strict';

import React, { Component } from 'react';
import {
  View,
  Text,
  //  StyleSheet,
  TouchableOpacity,
} from 'react-native';
import PropTypes from 'prop-types';

/**
 * 使用方法
 * 
 * 
   <Radio
            checked={this.state.checked}
            color={"#31bcfe"}
            size={20}
            onPress={() => {
              this.setState({
                checked: !this.state.checked
              })
            }}
          />

 */

export default class Radio extends Component {
  static defaultProps = {
    // radioStyle: '', //单元框样式
    size: 30,
    color: '#ffb910',
    checked: true,
  };
  static propTypes = {
    checked: PropTypes.bool, //是否选中
    size: PropTypes.object, // 单选框的大小
    color: PropTypes.object, // 单选框的背景色
    onPress: PropTypes.func,
    // radioStyle: PropTypes.object, // 单选的样式
  };

  constructor(props) {
    super(props);
  }

  render() {
    const { checked, radioStyle, size, color, onPress } = this.props;
    const propsStyleView = { height: size * 0.92, width: size * 0.92 };
    const propsStyle = { fontFamily: 'iconfont', fontSize: size, color: color };
    const noCheckStyle = {
      borderRadius: (size * 0.92) / 2,
      borderWidth: 1,
      borderColor: color,
    };
    return (
      <View>
        {checked ? (
          <TouchableOpacity onPress={onPress}>
            <Text style={[propsStyle]}>&#xe672;</Text>
          </TouchableOpacity>
        ) : (
          <TouchableOpacity
            style={[propsStyleView, noCheckStyle]}
            onPress={onPress}
          />
        )}
      </View>
    );
  }
}

// const styles = StyleSheet.create({
//   radioLightStyle: {
//     color: '#ffb910',
//     fontFamily: 'iconfont',
//     fontSize: 30,
//   },

//   noradioStyle: {
//     width: 30,
//     height: 30,
//     borderRadius: 15,
//     borderWidth: 1,
//     borderColor: '#ffb910',
//   },
// });
